using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes.DomainAttributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Enums;
using System.Collections.Generic;
using System.ComponentModel;

namespace Baci.ArcGIS._DataManagementTools._LayersandTableViews
{
    /// <summary>
    /// <para>Make Query Layer</para>
    /// <para>Creates a query layer  from a DBMS table based on an input SQL select statement.</para>
    /// <para>根据输入 SQL select 语句从 DBMS 表创建查询层。</para>
    /// </summary>    
    [DisplayName("Make Query Layer")]
    public class MakeQueryLayer : AbstractGPProcess
    {
        /// <summary>
        /// 无参构造
        /// </summary>
        public MakeQueryLayer()
        {

        }

        /// <summary>
        /// 有参构造
        /// </summary>
        /// <param name="_input_database">
        /// <para>Input Database Connection</para>
        /// <para>The database connection file that contains the data to be queried.</para>
        /// <para>包含要查询的数据的数据库连接文件。</para>
        /// </param>
        /// <param name="_out_layer_name">
        /// <para>Output Layer Name</para>
        /// <para>The output name of the feature layer or table view to be created.</para>
        /// <para>要创建的要素图层或表视图的输出名称。</para>
        /// </param>
        /// <param name="_query">
        /// <para>Query</para>
        /// <para><xdoc>
        ///   <para>The SQL statement that defines the select query to be executed in the database.</para>
        ///   <para>This string must pass validation before remaining controls will be enabled. Validation will be triggered when you click outside this input box. The validation process executes the query in the database and verifies whether the result of the SQL query meets the data modeling standards enforced by ArcGIS. If the validation fails, the tool will return a warning. The only exception is for Model Builder, in which case validation will not be triggered if the input is derived data.</para>
        ///   <para>Rules for validation are as follows:
        ///   <bulletList>
        ///     <bullet_item>The result of the SQL query must have only one spatial field.  </bullet_item><para/>
        ///     <bullet_item>The result of the SQL query must have only one spatial reference.  </bullet_item><para/>
        ///     <bullet_item>The result of the SQL query must have only one entity type, such as point, multipoint, line, or polygon.  </bullet_item><para/>
        ///     <bullet_item>The result of the SQL query cannot have any field types not supported by ArcGIS; ArcGIS field data types describes the field types supported in ArcGIS.  </bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        ///   <para>Validation is especially important when working with data in spatial databases that do not enforce the same standards as ArcGIS.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>定义要在数据库中执行的 select 查询的 SQL 语句。</para>
        ///   <para>此字符串必须通过验证，然后才能启用其余控件。当您单击此输入框外时，将触发验证。验证过程将在数据库中执行查询，并验证 SQL 查询的结果是否符合 ArcGIS 强制执行的数据建模标准。如果验证失败，该工具将返回警告。唯一的例外是模型生成器，在这种情况下，如果输入是派生数据，则不会触发验证。</para>
        /// <para>验证规则如下：
        ///   <bulletList>
        ///     <bullet_item>SQL 查询的结果必须只有一个空间字段。</bullet_item><para/>
        ///     <bullet_item>SQL 查询的结果必须只有一个空间参考。</bullet_item><para/>
        ///     <bullet_item>SQL 查询的结果只能具有一种实体类型，例如点、多点、线或多边形。</bullet_item><para/>
        ///     <bullet_item>SQL 查询的结果不能包含 ArcGIS 不支持的任何字段类型;ArcGIS 字段数据类型描述了 ArcGIS 中支持的字段类型。 </bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        ///   <para>在空间数据库中处理与 ArcGIS 不强制执行相同标准的数据时，验证尤为重要。</para>
        /// </xdoc></para>
        /// </param>
        public MakeQueryLayer(object _input_database, object _out_layer_name, object _query)
        {
            this._input_database = _input_database;
            this._out_layer_name = _out_layer_name;
            this._query = _query;
        }
        public override string ToolboxName => "Data Management Tools";

        public override string ToolName => "Make Query Layer";

        public override string CallName => "management.MakeQueryLayer";

        public override List<string> AcceptEnvironments => ["outputCoordinateSystem", "workspace"];

        public override object[] ParameterInfo => [_input_database, _out_layer_name, _query, _oid_fields, _shape_type.GetGPValue(), _srid, _spatial_reference, _out_layer, _spatial_properties.GetGPValue(), _m_values.GetGPValue(), _z_values.GetGPValue(), _extent];

        /// <summary>
        /// <para>Input Database Connection</para>
        /// <para>The database connection file that contains the data to be queried.</para>
        /// <para>包含要查询的数据的数据库连接文件。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Input Database Connection")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _input_database { get; set; }


        /// <summary>
        /// <para>Output Layer Name</para>
        /// <para>The output name of the feature layer or table view to be created.</para>
        /// <para>要创建的要素图层或表视图的输出名称。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Output Layer Name")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _out_layer_name { get; set; }


        /// <summary>
        /// <para>Query</para>
        /// <para><xdoc>
        ///   <para>The SQL statement that defines the select query to be executed in the database.</para>
        ///   <para>This string must pass validation before remaining controls will be enabled. Validation will be triggered when you click outside this input box. The validation process executes the query in the database and verifies whether the result of the SQL query meets the data modeling standards enforced by ArcGIS. If the validation fails, the tool will return a warning. The only exception is for Model Builder, in which case validation will not be triggered if the input is derived data.</para>
        ///   <para>Rules for validation are as follows:
        ///   <bulletList>
        ///     <bullet_item>The result of the SQL query must have only one spatial field.  </bullet_item><para/>
        ///     <bullet_item>The result of the SQL query must have only one spatial reference.  </bullet_item><para/>
        ///     <bullet_item>The result of the SQL query must have only one entity type, such as point, multipoint, line, or polygon.  </bullet_item><para/>
        ///     <bullet_item>The result of the SQL query cannot have any field types not supported by ArcGIS; ArcGIS field data types describes the field types supported in ArcGIS.  </bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        ///   <para>Validation is especially important when working with data in spatial databases that do not enforce the same standards as ArcGIS.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>定义要在数据库中执行的 select 查询的 SQL 语句。</para>
        ///   <para>此字符串必须通过验证，然后才能启用其余控件。当您单击此输入框外时，将触发验证。验证过程将在数据库中执行查询，并验证 SQL 查询的结果是否符合 ArcGIS 强制执行的数据建模标准。如果验证失败，该工具将返回警告。唯一的例外是模型生成器，在这种情况下，如果输入是派生数据，则不会触发验证。</para>
        /// <para>验证规则如下：
        ///   <bulletList>
        ///     <bullet_item>SQL 查询的结果必须只有一个空间字段。</bullet_item><para/>
        ///     <bullet_item>SQL 查询的结果必须只有一个空间参考。</bullet_item><para/>
        ///     <bullet_item>SQL 查询的结果只能具有一种实体类型，例如点、多点、线或多边形。</bullet_item><para/>
        ///     <bullet_item>SQL 查询的结果不能包含 ArcGIS 不支持的任何字段类型;ArcGIS 字段数据类型描述了 ArcGIS 中支持的字段类型。 </bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        ///   <para>在空间数据库中处理与 ArcGIS 不强制执行相同标准的数据时，验证尤为重要。</para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Query")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _query { get; set; }


        /// <summary>
        /// <para>Unique Identifier Field(s)</para>
        /// <para>One or more fields from the SELECT statement SELECT list that will generate a dynamic, unique row identifier.</para>
        /// <para>SELECT 语句 SELECT 列表中的一个或多个字段，这些字段将生成动态的唯一行标识符。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Unique Identifier Field(s)")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public List<object> _oid_fields { get; set; } = null;


        /// <summary>
        /// <para>Shape Type</para>
        /// <para><xdoc>
        ///   <para>Specifies the shape type of the query layer. Only those records from the result set of the query that match the specified shape type will be used in the output query layer. Tool validation will attempt to set this property based on the first record in the result set. This can be changed before executing the tool if it is not the desired output shape type. This parameter is ignored if the result set of the query does not return a geometry field.</para>
        ///   <bulletList>
        ///     <bullet_item>Point—The output query layer will use point geometry.</bullet_item><para/>
        ///     <bullet_item>Multipoint—The output query layer will use multipoint geometry.</bullet_item><para/>
        ///     <bullet_item>Polygon—The output query layer will use polygon geometry.</bullet_item><para/>
        ///     <bullet_item>Polyline—The output query layer will use polyline geometry.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定查询图层的形状类型。只有查询结果集中与指定形状类型匹配的记录才会在输出查询图层中使用。工具验证将尝试根据结果集中的第一条记录设置此属性。如果工具不是所需的输出形状类型，则可以在执行工具之前更改此设置。如果查询的结果集未返回几何字段，则忽略此参数。</para>
        ///   <bulletList>
        ///     <bullet_item>点 - 输出查询图层将使用点几何。</bullet_item><para/>
        ///     <bullet_item>多点 - 输出查询图层将使用多点几何。</bullet_item><para/>
        ///     <bullet_item>面—输出查询图层将使用面几何。</bullet_item><para/>
        ///     <bullet_item>折线—输出查询图层将使用折线几何。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Shape Type")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _shape_type_value? _shape_type { get; set; } = null;

        public enum _shape_type_value
        {
            /// <summary>
            /// <para>Point</para>
            /// <para>Point—The output query layer will use point geometry.</para>
            /// <para>点 - 输出查询图层将使用点几何。</para>
            /// </summary>
            [Description("Point")]
            [GPEnumValue("POINT")]
            _POINT,

            /// <summary>
            /// <para>Multipoint</para>
            /// <para>Multipoint—The output query layer will use multipoint geometry.</para>
            /// <para>多点 - 输出查询图层将使用多点几何。</para>
            /// </summary>
            [Description("Multipoint")]
            [GPEnumValue("MULTIPOINT")]
            _MULTIPOINT,

            /// <summary>
            /// <para>Polygon</para>
            /// <para>Polygon—The output query layer will use polygon geometry.</para>
            /// <para>面—输出查询图层将使用面几何。</para>
            /// </summary>
            [Description("Polygon")]
            [GPEnumValue("POLYGON")]
            _POLYGON,

            /// <summary>
            /// <para>Polyline</para>
            /// <para>Polyline—The output query layer will use polyline geometry.</para>
            /// <para>折线—输出查询图层将使用折线几何。</para>
            /// </summary>
            [Description("Polyline")]
            [GPEnumValue("POLYLINE")]
            _POLYLINE,

        }

        /// <summary>
        /// <para>SRID</para>
        /// <para>The spatial reference identifier (SRID) value for queries that return geometry. Only those records from the result set of the query that match the specified SRID value will be used in the output query layer. Tool validation will attempt to set this property based on the first record in the result set. This can be changed before executing the tool if it is not the desired output SRID value. This parameter is ignored if the result set of the query does not return a geometry field.</para>
        /// <para>返回几何图形的查询的空间参考标识符 （SRID） 值。只有查询结果集中与指定 SRID 值匹配的记录才会在输出查询图层中使用。工具验证将尝试根据结果集中的第一条记录设置此属性。如果它不是所需的输出 SRID 值，则可以在执行工具之前更改此值。如果查询的结果集未返回几何字段，则忽略此参数。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("SRID")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _srid { get; set; } = null;


        /// <summary>
        /// <para>Coordinate System</para>
        /// <para>The coordinate system that will be used by the output query layer. Tool validation will attempt to set this property based on the first record in the result set. This can be changed before executing the tool if it is not the desired output coordinate system. This parameter is ignored if the result set of the query does not return a geometry field.</para>
        /// <para>输出查询图层将使用的坐标系。工具验证将尝试根据结果集中的第一条记录设置此属性。如果该工具不是所需的输出坐标系，则可以在执行该工具之前进行更改。如果查询的结果集未返回几何字段，则忽略此参数。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Coordinate System")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _spatial_reference { get; set; } = null;


        /// <summary>
        /// <para>Output Layer</para>
        /// <para></para>
        /// <para></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Output Layer")]
        [Description("")]
        [Option(OptionTypeEnum.derived)]
        public object _out_layer { get; set; }


        /// <summary>
        /// <para>Define the spatial properties of the layer</para>
        /// <para><xdoc>
        ///   <para>Specifies how the spatial properties for the layer will be defined.</para>
        ///   <para>During the validation process, dimensionality, geometry type, spatial reference, SRID, and unique identifier properties will be set on the query layer. These values are based on the first row returned in the query. To manually define these properties instead of the tool querying the table to get them, the Define spatial properties for the layer parameter is checked by default.</para>
        ///   <bulletList>
        ///     <bullet_item>Checked—Manually define the spatial properties of the layer. This is the default.</bullet_item><para/>
        ///     <bullet_item>Unchecked—Layer properties will be determined based on the first row returned in the query.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定如何定义图层的空间属性。</para>
        ///   <para>在验证过程中，将在查询图层上设置维度、几何类型、空间参考、SRID 和唯一标识符属性。这些值基于查询中返回的第一行。要手动定义这些属性，而不是通过查询表来获取这些属性的工具，默认情况下会选中定义图层的空间属性参数。</para>
        ///   <bulletList>
        ///     <bullet_item>选中 - 手动定义图层的空间属性。这是默认设置。</bullet_item><para/>
        ///     <bullet_item>未选中 - 图层属性将根据查询中返回的第一行确定。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Define the spatial properties of the layer")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _spatial_properties_value _spatial_properties { get; set; } = _spatial_properties_value._true;

        public enum _spatial_properties_value
        {
            /// <summary>
            /// <para>DEFINE_SPATIAL_PROPERTIES</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("DEFINE_SPATIAL_PROPERTIES")]
            [GPEnumValue("true")]
            _true,

            /// <summary>
            /// <para>DO_NOT_DEFINE_SPATIAL_PROPERTIES</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("DO_NOT_DEFINE_SPATIAL_PROPERTIES")]
            [GPEnumValue("false")]
            _false,

        }

        /// <summary>
        /// <para>Coordinates include M values</para>
        /// <para><xdoc>
        ///   <para>Specifies whether the layer will have m-values.</para>
        ///   <bulletList>
        ///     <bullet_item>Checked—The layer will have m-values.</bullet_item><para/>
        ///     <bullet_item>Unchecked—The layer will not have m-values. This is the default.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定图层是否具有 m 值。</para>
        ///   <bulletList>
        ///     <bullet_item>选中 - 图层将具有 m 值。</bullet_item><para/>
        ///     <bullet_item>未选中 - 图层将不具有 m 值。这是默认设置。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Coordinates include M values")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _m_values_value _m_values { get; set; } = _m_values_value._false;

        public enum _m_values_value
        {
            /// <summary>
            /// <para>INCLUDE_M_VALUES</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("INCLUDE_M_VALUES")]
            [GPEnumValue("true")]
            _true,

            /// <summary>
            /// <para>DO_NOT_INCLUDE_M_VALUES</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("DO_NOT_INCLUDE_M_VALUES")]
            [GPEnumValue("false")]
            _false,

        }

        /// <summary>
        /// <para>Coordinates include Z values</para>
        /// <para><xdoc>
        ///   <para>Specifies whether the layer will have z-values.</para>
        ///   <bulletList>
        ///     <bullet_item>Checked—The layer will have z-values.</bullet_item><para/>
        ///     <bullet_item>Unchecked—The layer will not have z-values. This is the default.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定图层是否具有 z 值。</para>
        ///   <bulletList>
        ///     <bullet_item>选中 - 图层将具有 z 值。</bullet_item><para/>
        ///     <bullet_item>未选中 - 图层将不具有 z 值。这是默认设置。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Coordinates include Z values")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _z_values_value _z_values { get; set; } = _z_values_value._false;

        public enum _z_values_value
        {
            /// <summary>
            /// <para>INCLUDE_Z_VALUES</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("INCLUDE_Z_VALUES")]
            [GPEnumValue("true")]
            _true,

            /// <summary>
            /// <para>DO_NOT_INCLUDE_Z_VALUES</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("DO_NOT_INCLUDE_Z_VALUES")]
            [GPEnumValue("false")]
            _false,

        }

        /// <summary>
        /// <para>Extent</para>
        /// <para><xdoc>
        ///   <para>The extent of the layer. This parameter is only used if Define spatial properties for the layer is checked (spatial_properties = DEFINE_SPATIAL_PROPERTIES in Python). The extent must include all features in the table.</para>
        ///   <bulletList>
        ///     <bullet_item>Default—The extent will be based on the maximum extent of all participating inputs. This is the default.</bullet_item><para/>
        ///     <bullet_item>Current Display Extent—The extent is equal to the data frame or visible display. The option is not available when there is no active map.</bullet_item><para/>
        ///     <bullet_item>As Specified Below—The extent will be based on the minimum and maximum extent values specified.</bullet_item><para/>
        ///     <bullet_item>Browse—The extent will be based on an existing dataset.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>图层的范围。仅当选中定义图层的空间属性（Python 中为 spatial_properties = DEFINE_SPATIAL_PROPERTIES）时，才使用此参数。范围必须包括表中的所有要素。</para>
        ///   <bulletList>
        ///     <bullet_item>默认值 - 范围将基于所有参与输入的最大范围。这是默认设置。</bullet_item><para/>
        ///     <bullet_item>当前显示范围 - 范围等于数据框或可见显示。当没有活动地图时，该选项不可用。</bullet_item><para/>
        ///     <bullet_item>如下所述 - 范围将基于指定的最小和最大范围值。</bullet_item><para/>
        ///     <bullet_item>浏览 - 范围将基于现有数据集。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Extent")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _extent { get; set; } = null;


        public MakeQueryLayer SetEnv(object outputCoordinateSystem = null, object workspace = null)
        {
            base.SetEnv(outputCoordinateSystem: outputCoordinateSystem, workspace: workspace);
            return this;
        }

    }

}